<template>
  <div class="login">
    <h1>欢迎登录</h1>
    <el-input v-model="username" placeholder="请输入用户名">用户名</el-input>
    <el-input
      placeholder="请输入密码"
      v-model="password"
      show-password
      id="password"
      >密码</el-input
    >
    <el-row>
      <el-button @click="Login" type="primary">登录</el-button>
    </el-row>
  </div>
</template>

<script>
import axios, { Axios } from "axios";
import querystring from "querystring";
export default {
  name: "Login",
  data() {
    return {
      username: "",
      password: "",
    };
  },
  methods: {
    Login() {
      axios({
        method: "post",
        url: "http://localhost:8080/user/login",
        data: {
          username: this.username,
          password: this.password,
        },
        // headers: { "content-type": "application/json " },
        // headers: {
        //   "Content-Type": "application/json", // 使用 JSON 类型的请求头
        // },
      }).then((res) => {
        if (res.data != null) {
          this.$router.push({
            name: "logininfo",
            params: {
              id: res.data.id,
            },
          });
        }
      });
    },
  },
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.el-input.el-input--suffix {
  padding-top: 20px;
}
.login {
  width: 200px;
  padding-left: 600px;
}
.el-row {
  margin-top: 10px;
}
</style>
